package com.atmyc.yygh.hospital.controller;


import com.atmyc.yygh.common.result.Result;
import com.atmyc.yygh.hospital.service.HospitalService;
import com.atmyc.yygh.vo.hosp.HospitalQueryVo;
import com.atmyc.yygh.vo.hosp.HospitalSetQueryVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@Api(tags = "医院列表管理")
@RestController
@RequestMapping("/admin/hosp/hospi")
@CrossOrigin
public class HospitalController {
    @Autowired
    private HospitalService hospitalService;

    //医院列表
    @ApiOperation(value = "获取医院列表")
    @GetMapping("list/{page}/{limit}")
    public Result listHosp(@PathVariable Integer page, @PathVariable Integer limit, HospitalQueryVo hospitalQueryVo){
        Page pageModel = hospitalService.selectHospPage(page,limit,hospitalQueryVo);
        return Result.ok(pageModel);

    }

    //更新医院状态
    @ApiOperation(value = "更新医院状态")
    @GetMapping("updateHospital/{id}/{status}")
    public Result updateHospiatl(@PathVariable String id,@PathVariable Integer status){
        System.out.println("===============");
        System.out.println("id="+id);
        hospitalService.updateHospital(id,status);
        return Result.ok();
    }

    //获取医院详情信息
    @ApiOperation(value = "获取医院详情信息")
    @GetMapping("getHospital/{id}")
    public Result getHospital(@PathVariable String id){
        Map<String, Object> hospiatlAndBookingRuleMap = hospitalService.show(id);
        return Result.ok(hospiatlAndBookingRuleMap);
    }
}
